package system.security.entity;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="se_resource_type")
public class ResourceType {
	
	private String name;
	private boolean accessControl = false;
	
	public ResourceType(){}
	
	public ResourceType(String name){
		this.name = name;
	}
	
	@Id
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column
	public boolean isAccessControl() {
		return accessControl;
	}

	public void setAccessControl(boolean accessControl) {
		this.accessControl = accessControl;
	}

	protected Set<AuthorityType> authorityTypes;

	@ManyToMany(cascade = {CascadeType.PERSIST}, fetch=FetchType.LAZY)
	@JoinTable(name = "se_resourcetype_authoritytype", joinColumns = { @JoinColumn(name = "resource_type_id") }, inverseJoinColumns = { @JoinColumn(name = "authority_type_id") })
	public Set<AuthorityType> getAuthorityTypes() {
		return authorityTypes;
	}

	public void setAuthorityTypes(Set<AuthorityType> authorityTypes) {
		this.authorityTypes = authorityTypes;
	}
	
}
